import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3



Page{
    id:root
    title: "Button"

    DropArea {
        x:200
        y:200
        width: 400
        height: 400
        Rectangle {
            id:backCo
            anchors.fill: parent
            color: "green"
            visible: parent.containsDrag
        }

        onDropped: {
            console.log("drop")
            if(drop.hasUrls){
                for(var i = 0; i < drop.urls.length; i++){
                    console.log(drop.urls.length);
                    console.log(drop.urls[i]);
                }
            }
            //console.log(drop.text)
        }


    }
    Rectangle {
        id:rect1
        x:250
        y:250
        width: 40; height: 40
        color: "red"

        Drag.active: dragArea.drag.active
        Drag.hotSpot.x: rect1.x
        Drag.hotSpot.y: rect1.y

        MouseArea {
          id: dragArea
          anchors.fill: parent
          acceptedButtons: Qt.LeftButton
          drag.target: parent
          drag.axis: Drag.XAxis
        }
    }

    Rectangle {
        id:rect2
        x:10
        y:10
        width: 40; height: 40
        color: "white"

        Drag.active: dragArea1.drag.active
        Drag.hotSpot.x: rect2.x
        Drag.hotSpot.y: rect2.y

        MouseArea {
          id: dragArea1
          anchors.fill: parent
          acceptedButtons:  Qt.RightButton
          drag.target: parent
          drag.axis: Drag.YAxis
        }
    }

    Rectangle {
        id:rect3
        x:500
        y:10
        width: 40; height: 40
        color: "yellow"

        Drag.active: dragArea2.drag.active
        Drag.hotSpot.x: rect3.x
        Drag.hotSpot.y: rect3.y
        Drag.mimeData: {
                      "text/plain": "Copied text"
        }
        //Drag.imageSource: "file:///G:/Temp/Pic/pic.png"
        Drag.keys:"yellow"

        MouseArea {
          id: dragArea2
          anchors.fill: parent
          onReleased: parent.Drag.drop()
          acceptedButtons: Qt.LeftButton | Qt.RightButton
          drag.target: parent
        }
    }

}
